/*
 * Phase.cpp
 *
 *  Created on: 16/10/2011
 *      Author: godinho
 */

#include <localview/Phase.h>
#include <localview/Link.h>
#include <log.h>

namespace localview {

Phase::Phase() {
}

Phase::~Phase() {
}

int Phase::addLink(Link* link, char status) {
	mLinks.push_back(link);
	int index = mLinks.size()-1;
	mStatus.push_back('-');
	setStatus(index, status);
}

int Phase::getLinkCount() {
	return mLinks.size();
}

Link* Phase::getLink(int index) {
	return mLinks[index];
}

void Phase::setStatus(const char* status) {
	for(int i = 0; status[i]; i++) {
		setStatus(i, status[i]);
	}
}

void Phase::setStatus(int linkIndex, char status) {
	mStatus[linkIndex] = status;
}

char Phase::getStatus(int index) {
	return mStatus[index];
}

int Phase::getDuration() {
	return mDuration;
}

void Phase::setDuration(int d) {
	mDuration = d;
}

std::vector<Link*> Phase::getLinks() {
	return mLinks;
}

std::vector<Link*> Phase::getLinksOnStatus(char s) {
	std::vector<Link*> links;

	for(int i = 0; i < mLinks.size(); i++) {
		if(mStatus[i] == s) {
			links.push_back(mLinks[i]);
		}
	}

	return links;
}

}
